﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
using System.Diagnostics;

namespace System.Collections.Generic
{
    /// <summary>
    /// Extensions to <see cref="IEnumerable"/> class.
    /// </summary>
    public static class CollectionExtensions
    {
        /// <summary>
        /// Dumps the contents of the sequence of elements to the Trace output separated by semi-colons.
        /// </summary>
        /// <param name="en"></param>
        public static void Dump(this IEnumerable en)
        {
            Dump(en, false);
        }

        /// <summary>
        /// Dumps the contents of the sequence of elements to the Trace output separated by semi-colons or newline character.
        /// </summary>
        /// <param name="en"></param>
        /// <param name="inColumn">uses newline (true) or semicolon as separator</param>
        public static void Dump(this IEnumerable en, bool inColumn)
        {
            string sep = (inColumn) ? Environment.NewLine : "; ";
            foreach (var item in en)
            {
                Trace.Write(item + sep);
            }
            Trace.Write(Environment.NewLine);
        }
    }
}
